<?php
  if(command("setlevel",50)){
    $userLevelMod=strtolower($paramA[0]);
    $levelLevelMod=(int)$paramA[1];
    $levels[$userLevelMod]=$levelLevelMod;
    SendCommand("PRIVMSG $channel :".$paramA[0]." now has an access level of ".$levels[$userLevelMod]);
    updateAccess();
  }

  if(command("ignore",50)){
    $userLevelMod=strtolower($paramA[0]);
    $levels[$userLevelMod]=0;
    SendCommand("PRIVMSG $channel :".$paramA[0]." has been ignored [access level 0]");
    updateAccess();
  }

  if(command("unignore",50)){
    $userLevelMod=strtolower($paramA[0]);
    $levels[$userLevelMod]=1;
    SendCommand("PRIVMSG $channel :".$paramA[0]." now has an access level of ".$levels[$userLevelMod]);
    updateAccess();
  }

  if(command("level")){
    $userLevel=strtolower($paramA[0]);
    if(empty($userLevel)){
      $userLevel=strtolower($sender);
      if(!$levels[$userLevel]){
        $userLevel=strtolower($senderHost);
      }
      if($levels[$userLevel]){
        SendCommand("PRIVMSG $channel :$sender: your access level is ".$levels[$userLevel]);
      } else {
        SendCommand("PRIVMSG $channel :$sender: your access level hasn't been set, so it defaults to 1");
      }
    } else {
      if($levels[$userLevel]){
        SendCommand("PRIVMSG $channel :".$paramA[0]."'s access level is ".$levels[$userLevel]);
      } else {
        SendCommand("PRIVMSG $channel :".$paramA[0]."'s access level hasn't been set, so it defaults to 1");
      }
    }
  }

  if(command("levels")){
    $levelStr="";
    foreach($levels as $user=>$level){
      $levelStr.="$user: $level, ";
    }
    $levelStr=trim($levelStr,", ");
    if(empty($levelStr)){
      $levelStr="No set access levels... This shouldn't happen people...";
    }
    SendCommand("PRIVMSG $channel :$levelStr");

  }
?>